package py.pathMaker;

import java.io.File;

public class PathMaker {
	
	public static File sourceBasePath=null;	
	public static File desBasePath=null;
//	public static File errPath=null;
	
	public static void setSourceBasePath(File sourcePath) 
	{
		PathMaker.sourceBasePath = sourcePath;
		File parentPath=sourcePath.getParentFile();
		PathMaker.desBasePath=new File(parentPath.getAbsolutePath()+File.separator+"CombResult"+File.separator);
	}	
	/**
	 * 得到结果文件路径
	 * @param sourcePath
	 * @return
	 */
	public String getResultPath(String sourcePath)
	{
		String returnString=desBasePath.getAbsolutePath()+sourcePath.substring((int)((sourceBasePath.getAbsolutePath()).length()));
		return returnString;
	}
	
	public synchronized boolean createDir(String filename) {
		boolean iscreated = true;
		File cfile = new File(filename);
		File pathDir=cfile.getParentFile();
		if (!cfile.exists()) {
			iscreated = cfile.mkdirs();
		}
		return iscreated;
	}

}
